--
-- PostgreSQL database dump
--

-- Started on 2011-05-30 23:04:40

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- TOC entry 1989 (class 1262 OID 16395)
-- Name: sispac; Type: DATABASE; Schema: -; Owner: -
--

CREATE DATABASE sispac WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'Portuguese_Brazil.1252' LC_CTYPE = 'Portuguese_Brazil.1252';


\connect sispac

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- TOC entry 360 (class 2612 OID 16386)
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
--

CREATE PROCEDURAL LANGUAGE plpgsql;


SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- TOC entry 1547 (class 1259 OID 16396)
-- Dependencies: 6
-- Name: banco; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE banco (
    id_banco integer NOT NULL,
    id_funcionario integer,
    id_status integer,
    descricao character varying(100) NOT NULL,
    tipo_conta numeric(1,0),
    agencia character varying(10),
    conta character varying(10)
);


--
-- TOC entry 1992 (class 0 OID 0)
-- Dependencies: 1547
-- Name: TABLE banco; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE banco IS 'TABELA RESPONSAVEL POR ARMAZENAR INFORMACOES DOS BANCOS
';


--
-- TOC entry 1993 (class 0 OID 0)
-- Dependencies: 1547
-- Name: COLUMN banco.id_banco; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN banco.id_banco IS 'id_banco';


--
-- TOC entry 1994 (class 0 OID 0)
-- Dependencies: 1547
-- Name: COLUMN banco.id_funcionario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN banco.id_funcionario IS 'id_funcionario';


--
-- TOC entry 1995 (class 0 OID 0)
-- Dependencies: 1547
-- Name: COLUMN banco.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN banco.id_status IS 'id_status';


--
-- TOC entry 1996 (class 0 OID 0)
-- Dependencies: 1547
-- Name: COLUMN banco.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN banco.descricao IS 'descricao';


--
-- TOC entry 1997 (class 0 OID 0)
-- Dependencies: 1547
-- Name: COLUMN banco.tipo_conta; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN banco.tipo_conta IS 'tipo_conta';


--
-- TOC entry 1998 (class 0 OID 0)
-- Dependencies: 1547
-- Name: COLUMN banco.agencia; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN banco.agencia IS 'agencia';


--
-- TOC entry 1999 (class 0 OID 0)
-- Dependencies: 1547
-- Name: COLUMN banco.conta; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN banco.conta IS 'conta';


--
-- TOC entry 1548 (class 1259 OID 16399)
-- Dependencies: 1547 6
-- Name: banco_id_banco_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE banco_id_banco_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2000 (class 0 OID 0)
-- Dependencies: 1548
-- Name: banco_id_banco_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE banco_id_banco_seq OWNED BY banco.id_banco;


--
-- TOC entry 1549 (class 1259 OID 16401)
-- Dependencies: 6
-- Name: categoria; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE categoria (
    id_categoria integer NOT NULL,
    id_status integer,
    descricao character varying(50) NOT NULL
);


--
-- TOC entry 2001 (class 0 OID 0)
-- Dependencies: 1549
-- Name: TABLE categoria; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE categoria IS 'categoria';


--
-- TOC entry 2002 (class 0 OID 0)
-- Dependencies: 1549
-- Name: COLUMN categoria.id_categoria; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN categoria.id_categoria IS 'id_categoria';


--
-- TOC entry 2003 (class 0 OID 0)
-- Dependencies: 1549
-- Name: COLUMN categoria.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN categoria.id_status IS 'id_status';


--
-- TOC entry 2004 (class 0 OID 0)
-- Dependencies: 1549
-- Name: COLUMN categoria.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN categoria.descricao IS 'descricao';


--
-- TOC entry 1550 (class 1259 OID 16404)
-- Dependencies: 1549 6
-- Name: categoria_id_categoria_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE categoria_id_categoria_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2005 (class 0 OID 0)
-- Dependencies: 1550
-- Name: categoria_id_categoria_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE categoria_id_categoria_seq OWNED BY categoria.id_categoria;


--
-- TOC entry 1551 (class 1259 OID 16406)
-- Dependencies: 1859 6
-- Name: clientes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE clientes (
    id_cliente integer NOT NULL,
    id_funcionario integer,
    id_banco integer,
    id_status integer,
    nome character varying(255) NOT NULL,
    estado_civil character varying(20),
    dt_nascimento date,
    cpf character varying(15),
    rg character varying(15),
    rg_localidade character varying(6),
    telefone character varying(15),
    celular character varying(15),
    mae character varying(255),
    pai character varying(255),
    profissao character varying(50),
    empresa_fantasia character varying(80),
    empresa_razao character varying(255),
    empresa_telefone character varying(15),
    empresa_contato character varying(255),
    empresa_endereco character varying(255),
    vlr_salario character varying(5),
    conjugue_nome character varying(255),
    conjugue_cpf character varying(15),
    conjugue_rg character varying(15),
    conjugue_rg_localidade character varying(6),
    conjugue_celular character varying(15),
    conjugue_profissao character varying(50),
    conjugue_empresa_nome character varying(255),
    conjugue_salario numeric(5,2),
    observasao text,
    dt_criacao timestamp without time zone DEFAULT now(),
    dt_data_modficacao timestamp without time zone
);


--
-- TOC entry 2006 (class 0 OID 0)
-- Dependencies: 1551
-- Name: TABLE clientes; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE clientes IS '- TABELA RESPONSAVEL POR ARMAZENAR INFORMACOES DOS CLIENTES -
';


--
-- TOC entry 2007 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.id_cliente; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.id_cliente IS 'id_cliente';


--
-- TOC entry 2008 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.id_funcionario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.id_funcionario IS 'id_funcionario';


--
-- TOC entry 2009 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.id_banco; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.id_banco IS 'id_banco';


--
-- TOC entry 2010 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.id_status IS 'id_status';


--
-- TOC entry 2011 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.nome; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.nome IS 'nome';


--
-- TOC entry 2012 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.estado_civil; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.estado_civil IS 'estado_civil';


--
-- TOC entry 2013 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.dt_nascimento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.dt_nascimento IS 'dt_nascimento';


--
-- TOC entry 2014 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.cpf; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.cpf IS 'cpf';


--
-- TOC entry 2015 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.rg; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.rg IS 'rg';


--
-- TOC entry 2016 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.rg_localidade; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.rg_localidade IS 'rg_localidade';


--
-- TOC entry 2017 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.telefone; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.telefone IS 'telefone';


--
-- TOC entry 2018 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.celular; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.celular IS 'celular';


--
-- TOC entry 2019 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.mae; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.mae IS 'mae';


--
-- TOC entry 2020 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.pai; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.pai IS 'pai';


--
-- TOC entry 2021 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.profissao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.profissao IS 'profissao';


--
-- TOC entry 2022 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.empresa_fantasia; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.empresa_fantasia IS 'empresa_fantasia';


--
-- TOC entry 2023 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.empresa_razao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.empresa_razao IS 'empresa_razao';


--
-- TOC entry 2024 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.empresa_telefone; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.empresa_telefone IS 'empresa_telefone';


--
-- TOC entry 2025 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.empresa_contato; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.empresa_contato IS 'empresa_contato';


--
-- TOC entry 2026 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.empresa_endereco; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.empresa_endereco IS 'empresa_endereco';


--
-- TOC entry 2027 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.vlr_salario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.vlr_salario IS 'vlr_salario';


--
-- TOC entry 2028 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.conjugue_nome; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.conjugue_nome IS 'conjugue_nome';


--
-- TOC entry 2029 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.conjugue_cpf; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.conjugue_cpf IS 'conjugue_cpf';


--
-- TOC entry 2030 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.conjugue_rg; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.conjugue_rg IS 'conjugue_rg';


--
-- TOC entry 2031 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.conjugue_rg_localidade; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.conjugue_rg_localidade IS 'conjugue_rg_localidade';


--
-- TOC entry 2032 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.conjugue_celular; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.conjugue_celular IS 'conjugue_celular';


--
-- TOC entry 2033 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.conjugue_profissao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.conjugue_profissao IS 'conjugue_profissao';


--
-- TOC entry 2034 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.conjugue_empresa_nome; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.conjugue_empresa_nome IS 'conjugue_empresa_nome';


--
-- TOC entry 2035 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.conjugue_salario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.conjugue_salario IS 'conjugue_salario';


--
-- TOC entry 2036 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.observasao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.observasao IS 'observasao';


--
-- TOC entry 2037 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.dt_criacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.dt_criacao IS 'dt_criacao';


--
-- TOC entry 2038 (class 0 OID 0)
-- Dependencies: 1551
-- Name: COLUMN clientes.dt_data_modficacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN clientes.dt_data_modficacao IS 'dt_data_modficacao';


--
-- TOC entry 1552 (class 1259 OID 16413)
-- Dependencies: 6 1551
-- Name: clientes_id_cliente_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE clientes_id_cliente_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2039 (class 0 OID 0)
-- Dependencies: 1552
-- Name: clientes_id_cliente_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE clientes_id_cliente_seq OWNED BY clientes.id_cliente;


--
-- TOC entry 1553 (class 1259 OID 16415)
-- Dependencies: 6
-- Name: departamentos; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE departamentos (
    id_departamento integer NOT NULL,
    id_status integer,
    descricao character varying(50) NOT NULL,
    status numeric(1,0),
    data_criacao date
);


--
-- TOC entry 2040 (class 0 OID 0)
-- Dependencies: 1553
-- Name: TABLE departamentos; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE departamentos IS '- TABELA RESPONSAVEL POR ARMAZENAR INFORMACOES DOS DEPARTAMENTOS DA EMPRESA -';


--
-- TOC entry 2041 (class 0 OID 0)
-- Dependencies: 1553
-- Name: COLUMN departamentos.id_departamento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN departamentos.id_departamento IS 'id_departamento';


--
-- TOC entry 2042 (class 0 OID 0)
-- Dependencies: 1553
-- Name: COLUMN departamentos.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN departamentos.id_status IS 'id_status';


--
-- TOC entry 2043 (class 0 OID 0)
-- Dependencies: 1553
-- Name: COLUMN departamentos.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN departamentos.descricao IS 'descricao';


--
-- TOC entry 2044 (class 0 OID 0)
-- Dependencies: 1553
-- Name: COLUMN departamentos.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN departamentos.status IS 'status';


--
-- TOC entry 2045 (class 0 OID 0)
-- Dependencies: 1553
-- Name: COLUMN departamentos.data_criacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN departamentos.data_criacao IS 'data_criacao';


--
-- TOC entry 1554 (class 1259 OID 16418)
-- Dependencies: 1553 6
-- Name: departamentos_id_departamento_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE departamentos_id_departamento_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2046 (class 0 OID 0)
-- Dependencies: 1554
-- Name: departamentos_id_departamento_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE departamentos_id_departamento_seq OWNED BY departamentos.id_departamento;


--
-- TOC entry 1555 (class 1259 OID 16420)
-- Dependencies: 6
-- Name: enderecos; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE enderecos (
    id_endereco integer NOT NULL,
    id_tipoinserido integer,
    id_tpendereco integer,
    logradouro character varying(255),
    numero numeric(8,0),
    bairro character varying(100),
    cep character varying(9),
    cidade character varying(100),
    estado character varying(2),
    complemento character varying(255)
);


--
-- TOC entry 2047 (class 0 OID 0)
-- Dependencies: 1555
-- Name: TABLE enderecos; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE enderecos IS '- TABELA RESPONSAVEL POR ARMAZENAR TODOS OS ENDERECOS DO SISTEMA -';


--
-- TOC entry 2048 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.id_endereco; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.id_endereco IS 'id_endereco';


--
-- TOC entry 2049 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.id_tipoinserido; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.id_tipoinserido IS 'id_tipoinserido';


--
-- TOC entry 2050 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.id_tpendereco; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.id_tpendereco IS 'id_tpendereco';


--
-- TOC entry 2051 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.logradouro; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.logradouro IS 'logradouro';


--
-- TOC entry 2052 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.numero; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.numero IS 'numero';


--
-- TOC entry 2053 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.bairro; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.bairro IS 'bairro';


--
-- TOC entry 2054 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.cep; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.cep IS 'cep';


--
-- TOC entry 2055 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.cidade; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.cidade IS 'cidade';


--
-- TOC entry 2056 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.estado; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.estado IS 'estado';


--
-- TOC entry 2057 (class 0 OID 0)
-- Dependencies: 1555
-- Name: COLUMN enderecos.complemento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN enderecos.complemento IS 'complemento';


--
-- TOC entry 1556 (class 1259 OID 16426)
-- Dependencies: 1862 1863 6
-- Name: fornecedores; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE fornecedores (
    id_fornecedor integer NOT NULL,
    id_funcionario integer NOT NULL,
    id_status integer,
    nome_fantasia character varying(255),
    razao_social character varying(255),
    tipo character(1),
    cnpj character varying(20),
    email character varying(100),
    site character varying(255),
    telefone character varying(15),
    telefone2 character varying(15),
    nome_contato character varying(255),
    observacao text,
    status numeric(1,0) DEFAULT 1,
    dt_criacao timestamp without time zone DEFAULT now(),
    dt_modificacao timestamp without time zone,
    id_funcionario_mod integer
);


--
-- TOC entry 2058 (class 0 OID 0)
-- Dependencies: 1556
-- Name: TABLE fornecedores; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE fornecedores IS '- TABELA RESPONSAVEL POR AMARZENAR INFORMACOES DOS FORNECEDORES -';


--
-- TOC entry 2059 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.id_fornecedor; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.id_fornecedor IS 'id_fornecedor';


--
-- TOC entry 2060 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.id_funcionario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.id_funcionario IS 'id_funcionario';


--
-- TOC entry 2061 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.id_status IS 'id_status';


--
-- TOC entry 2062 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.nome_fantasia; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.nome_fantasia IS 'nome_fantasia';


--
-- TOC entry 2063 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.razao_social; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.razao_social IS 'razao_social';


--
-- TOC entry 2064 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.tipo; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.tipo IS 'tipo';


--
-- TOC entry 2065 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.cnpj; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.cnpj IS 'social security number  / corporate taxpayer registry
';


--
-- TOC entry 2066 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.email; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.email IS 'email';


--
-- TOC entry 2067 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.site; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.site IS 'site';


--
-- TOC entry 2068 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.telefone; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.telefone IS 'telefone';


--
-- TOC entry 2069 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.telefone2; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.telefone2 IS 'telefone2';


--
-- TOC entry 2070 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.nome_contato; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.nome_contato IS 'nome_contato';


--
-- TOC entry 2071 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.observacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.observacao IS 'observacao';


--
-- TOC entry 2072 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.status IS '1=ATIVO/ENABLED 2=INATIVO/DISABLED
';


--
-- TOC entry 2073 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.dt_criacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.dt_criacao IS 'dt_criacao';


--
-- TOC entry 2074 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.dt_modificacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.dt_modificacao IS 'dt_modificacao';


--
-- TOC entry 2075 (class 0 OID 0)
-- Dependencies: 1556
-- Name: COLUMN fornecedores.id_funcionario_mod; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN fornecedores.id_funcionario_mod IS 'id_funcionario_mod';


--
-- TOC entry 1557 (class 1259 OID 16434)
-- Dependencies: 1556 6
-- Name: fornecedores_id_fornecedor_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE fornecedores_id_fornecedor_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2076 (class 0 OID 0)
-- Dependencies: 1557
-- Name: fornecedores_id_fornecedor_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE fornecedores_id_fornecedor_seq OWNED BY fornecedores.id_fornecedor;


--
-- TOC entry 1558 (class 1259 OID 16436)
-- Dependencies: 1865 1866 6
-- Name: funcionarios; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE funcionarios (
    id_funcionario integer NOT NULL,
    id_funcao integer NOT NULL,
    id_departamento integer,
    id_status integer,
    nomeusuario character varying(25) NOT NULL,
    senha character varying(15) NOT NULL,
    nome character varying(255) NOT NULL,
    dt_nascimento date,
    cpf character varying(15) NOT NULL,
    rg character varying(15) NOT NULL,
    rg_localidade character varying(6),
    telefone character varying(15),
    celular character varying(15),
    mae character varying(255),
    num_cart_trabalho character varying(80),
    status numeric(1,0) DEFAULT 1,
    dt_criacao timestamp without time zone DEFAULT now()
);


--
-- TOC entry 2077 (class 0 OID 0)
-- Dependencies: 1558
-- Name: TABLE funcionarios; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE funcionarios IS '- TABELA RESPONSAVEL POR ARMAZENAR INFORMACOES DOS FUNCIONARIOS DA EMPRESA -';


--
-- TOC entry 2078 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.id_funcionario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.id_funcionario IS 'id_funcionario';


--
-- TOC entry 2079 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.id_funcao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.id_funcao IS 'id_funcao';


--
-- TOC entry 2080 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.id_departamento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.id_departamento IS 'id_departamento';


--
-- TOC entry 2081 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.id_status IS 'id_status';


--
-- TOC entry 2082 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.nomeusuario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.nomeusuario IS 'nomeusuario';


--
-- TOC entry 2083 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.senha; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.senha IS 'senha';


--
-- TOC entry 2084 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.nome; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.nome IS 'nome';


--
-- TOC entry 2085 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.dt_nascimento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.dt_nascimento IS 'dt_nascimento';


--
-- TOC entry 2086 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.cpf; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.cpf IS 'cpf';


--
-- TOC entry 2087 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.rg; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.rg IS 'rg';


--
-- TOC entry 2088 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.rg_localidade; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.rg_localidade IS 'rg_localidade';


--
-- TOC entry 2089 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.telefone; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.telefone IS 'telefone';


--
-- TOC entry 2090 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.celular; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.celular IS 'celular';


--
-- TOC entry 2091 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.mae; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.mae IS 'mae';


--
-- TOC entry 2092 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.num_cart_trabalho; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.num_cart_trabalho IS 'num_cart_trabalho';


--
-- TOC entry 2093 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.status IS '1=ATIVO/ENABLED 2=INATIVO/DISABLED
';


--
-- TOC entry 2094 (class 0 OID 0)
-- Dependencies: 1558
-- Name: COLUMN funcionarios.dt_criacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcionarios.dt_criacao IS 'dt_criacao';


--
-- TOC entry 1559 (class 1259 OID 16444)
-- Dependencies: 6 1558
-- Name: funcionarios_id_funcionario_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE funcionarios_id_funcionario_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2095 (class 0 OID 0)
-- Dependencies: 1559
-- Name: funcionarios_id_funcionario_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE funcionarios_id_funcionario_seq OWNED BY funcionarios.id_funcionario;


--
-- TOC entry 1560 (class 1259 OID 16446)
-- Dependencies: 6
-- Name: funcoes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE funcoes (
    id_funcao integer NOT NULL,
    id_departamento integer NOT NULL,
    id_status integer,
    descricao character varying(50) NOT NULL
);


--
-- TOC entry 2096 (class 0 OID 0)
-- Dependencies: 1560
-- Name: TABLE funcoes; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE funcoes IS '- TABLE RESPONSAVEL POR ARMAZENAR INFORMACOES SOBRE AS FUNCOES DOS FUNCIONARIOS, CLIENTES -
';


--
-- TOC entry 2097 (class 0 OID 0)
-- Dependencies: 1560
-- Name: COLUMN funcoes.id_funcao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcoes.id_funcao IS 'id_funcao';


--
-- TOC entry 2098 (class 0 OID 0)
-- Dependencies: 1560
-- Name: COLUMN funcoes.id_departamento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcoes.id_departamento IS 'id_departamento';


--
-- TOC entry 2099 (class 0 OID 0)
-- Dependencies: 1560
-- Name: COLUMN funcoes.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcoes.id_status IS 'id_status';


--
-- TOC entry 2100 (class 0 OID 0)
-- Dependencies: 1560
-- Name: COLUMN funcoes.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN funcoes.descricao IS 'descricao';


--
-- TOC entry 1561 (class 1259 OID 16449)
-- Dependencies: 6 1560
-- Name: funcoes_id_funcao_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE funcoes_id_funcao_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2101 (class 0 OID 0)
-- Dependencies: 1561
-- Name: funcoes_id_funcao_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE funcoes_id_funcao_seq OWNED BY funcoes.id_funcao;


--
-- TOC entry 1562 (class 1259 OID 16451)
-- Dependencies: 6
-- Name: inadiplentes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE inadiplentes (
    id_cliente integer,
    id_inadiplente character(10)
);


--
-- TOC entry 2102 (class 0 OID 0)
-- Dependencies: 1562
-- Name: TABLE inadiplentes; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE inadiplentes IS 'inadiplentes';


--
-- TOC entry 2103 (class 0 OID 0)
-- Dependencies: 1562
-- Name: COLUMN inadiplentes.id_cliente; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN inadiplentes.id_cliente IS 'id_cliente';


--
-- TOC entry 2104 (class 0 OID 0)
-- Dependencies: 1562
-- Name: COLUMN inadiplentes.id_inadiplente; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN inadiplentes.id_inadiplente IS 'id_inadiplente';


--
-- TOC entry 1563 (class 1259 OID 16454)
-- Dependencies: 6
-- Name: log_sistema; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE log_sistema (
    id_log integer NOT NULL,
    id_ocorrencia integer,
    dt_criacao timestamp without time zone,
    ip character varying(20),
    observacao text
);


--
-- TOC entry 2105 (class 0 OID 0)
-- Dependencies: 1563
-- Name: TABLE log_sistema; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE log_sistema IS 'Tabela com os logs do funcioncario';


--
-- TOC entry 2106 (class 0 OID 0)
-- Dependencies: 1563
-- Name: COLUMN log_sistema.id_log; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN log_sistema.id_log IS 'id_log';


--
-- TOC entry 2107 (class 0 OID 0)
-- Dependencies: 1563
-- Name: COLUMN log_sistema.id_ocorrencia; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN log_sistema.id_ocorrencia IS 'id_ocorrencia';


--
-- TOC entry 2108 (class 0 OID 0)
-- Dependencies: 1563
-- Name: COLUMN log_sistema.dt_criacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN log_sistema.dt_criacao IS 'dt_criacao';


--
-- TOC entry 2109 (class 0 OID 0)
-- Dependencies: 1563
-- Name: COLUMN log_sistema.ip; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN log_sistema.ip IS 'ip';


--
-- TOC entry 2110 (class 0 OID 0)
-- Dependencies: 1563
-- Name: COLUMN log_sistema.observacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN log_sistema.observacao IS 'observacao';


--
-- TOC entry 1564 (class 1259 OID 16460)
-- Dependencies: 1563 6
-- Name: log_sistema_id_log_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE log_sistema_id_log_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2111 (class 0 OID 0)
-- Dependencies: 1564
-- Name: log_sistema_id_log_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE log_sistema_id_log_seq OWNED BY log_sistema.id_log;


--
-- TOC entry 1565 (class 1259 OID 16462)
-- Dependencies: 6
-- Name: pedidos; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE pedidos (
    id_pedido integer NOT NULL,
    id_cliente integer,
    id_pagamento integer,
    id_status integer,
    id_funcionario integer,
    numnota bigint,
    qtde_parcelas numeric(2,0),
    qtde_parcelas_pgto numeric(2,0),
    dt_utlimo_pgto timestamp without time zone,
    dt_pedido timestamp without time zone,
    vlr_desconto numeric(8,2),
    vlr_total numeric(8,2),
    vlr_ultimo_pgto numeric(8,2),
    vlr_total_aberto numeric(8,2),
    vlr_parcela numeric(8,2)
);


--
-- TOC entry 2112 (class 0 OID 0)
-- Dependencies: 1565
-- Name: TABLE pedidos; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE pedidos IS 'TABELA COM OS PEDIDOS REALIZADOS.';


--
-- TOC entry 2113 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.id_pedido; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.id_pedido IS 'id_pedido';


--
-- TOC entry 2114 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.id_cliente; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.id_cliente IS 'id_cliente';


--
-- TOC entry 2115 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.id_pagamento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.id_pagamento IS 'id_pagamento';


--
-- TOC entry 2116 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.id_status IS 'Verificar na tabela de status';


--
-- TOC entry 2117 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.id_funcionario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.id_funcionario IS 'id_funcionario';


--
-- TOC entry 2118 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.numnota; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.numnota IS 'numnota';


--
-- TOC entry 2119 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.qtde_parcelas; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.qtde_parcelas IS 'qtde_parcelas';


--
-- TOC entry 2120 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.qtde_parcelas_pgto; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.qtde_parcelas_pgto IS 'qtde_parcelas_pgto';


--
-- TOC entry 2121 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.dt_utlimo_pgto; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.dt_utlimo_pgto IS 'dt_utlimo_pgto';


--
-- TOC entry 2122 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.dt_pedido; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.dt_pedido IS 'dt_pedido';


--
-- TOC entry 2123 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.vlr_desconto; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.vlr_desconto IS 'vlr_desconto';


--
-- TOC entry 2124 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.vlr_total; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.vlr_total IS 'vlr_total';


--
-- TOC entry 2125 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.vlr_ultimo_pgto; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.vlr_ultimo_pgto IS 'vlr_ultimo_pgto';


--
-- TOC entry 2126 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.vlr_total_aberto; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.vlr_total_aberto IS 'vlr_total_aberto';


--
-- TOC entry 2127 (class 0 OID 0)
-- Dependencies: 1565
-- Name: COLUMN pedidos.vlr_parcela; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos.vlr_parcela IS 'vlr_parcela';


--
-- TOC entry 1566 (class 1259 OID 16465)
-- Dependencies: 6
-- Name: pedidos_det; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE pedidos_det (
    id_pedidodet integer NOT NULL,
    id_pedido integer,
    id_produto integer,
    id_cfop bigint,
    numnota bigint,
    qtde numeric,
    vlr_unit numeric(8,2),
    vlr_total numeric(8,2)
);


--
-- TOC entry 2128 (class 0 OID 0)
-- Dependencies: 1566
-- Name: TABLE pedidos_det; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE pedidos_det IS 'pedidos_det';


--
-- TOC entry 2129 (class 0 OID 0)
-- Dependencies: 1566
-- Name: COLUMN pedidos_det.id_pedidodet; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos_det.id_pedidodet IS 'id_pedidodet';


--
-- TOC entry 2130 (class 0 OID 0)
-- Dependencies: 1566
-- Name: COLUMN pedidos_det.id_pedido; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos_det.id_pedido IS 'id_pedido';


--
-- TOC entry 2131 (class 0 OID 0)
-- Dependencies: 1566
-- Name: COLUMN pedidos_det.id_produto; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos_det.id_produto IS 'id_produto';


--
-- TOC entry 2132 (class 0 OID 0)
-- Dependencies: 1566
-- Name: COLUMN pedidos_det.id_cfop; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos_det.id_cfop IS 'id_cfop';


--
-- TOC entry 2133 (class 0 OID 0)
-- Dependencies: 1566
-- Name: COLUMN pedidos_det.numnota; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos_det.numnota IS 'numnota';


--
-- TOC entry 2134 (class 0 OID 0)
-- Dependencies: 1566
-- Name: COLUMN pedidos_det.qtde; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos_det.qtde IS 'qtde';


--
-- TOC entry 2135 (class 0 OID 0)
-- Dependencies: 1566
-- Name: COLUMN pedidos_det.vlr_unit; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos_det.vlr_unit IS 'vlr_unit';


--
-- TOC entry 2136 (class 0 OID 0)
-- Dependencies: 1566
-- Name: COLUMN pedidos_det.vlr_total; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pedidos_det.vlr_total IS 'vlr_total';


--
-- TOC entry 1567 (class 1259 OID 16471)
-- Dependencies: 1566 6
-- Name: pedidos_det_id_pedidodet_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE pedidos_det_id_pedidodet_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2137 (class 0 OID 0)
-- Dependencies: 1567
-- Name: pedidos_det_id_pedidodet_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE pedidos_det_id_pedidodet_seq OWNED BY pedidos_det.id_pedidodet;


--
-- TOC entry 1568 (class 1259 OID 16473)
-- Dependencies: 1565 6
-- Name: pedidos_id_pedido_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE pedidos_id_pedido_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2138 (class 0 OID 0)
-- Dependencies: 1568
-- Name: pedidos_id_pedido_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE pedidos_id_pedido_seq OWNED BY pedidos.id_pedido;


--
-- TOC entry 1569 (class 1259 OID 16475)
-- Dependencies: 6
-- Name: pgto_efetuado; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE pgto_efetuado (
    id_pgtoefetuado character(10) NOT NULL,
    id_pedido integer,
    id_funcionario integer,
    id_tppagamento integer,
    id_cliente integer,
    id_status integer,
    dt_pagamento timestamp without time zone
);


--
-- TOC entry 2139 (class 0 OID 0)
-- Dependencies: 1569
-- Name: TABLE pgto_efetuado; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE pgto_efetuado IS 'Tabela com os pagamentos efetuados';


--
-- TOC entry 2140 (class 0 OID 0)
-- Dependencies: 1569
-- Name: COLUMN pgto_efetuado.id_pgtoefetuado; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pgto_efetuado.id_pgtoefetuado IS 'id_pgtoefetuado';


--
-- TOC entry 2141 (class 0 OID 0)
-- Dependencies: 1569
-- Name: COLUMN pgto_efetuado.id_pedido; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pgto_efetuado.id_pedido IS 'id_pedido';


--
-- TOC entry 2142 (class 0 OID 0)
-- Dependencies: 1569
-- Name: COLUMN pgto_efetuado.id_funcionario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pgto_efetuado.id_funcionario IS 'id_funcionario';


--
-- TOC entry 2143 (class 0 OID 0)
-- Dependencies: 1569
-- Name: COLUMN pgto_efetuado.id_tppagamento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pgto_efetuado.id_tppagamento IS 'id_tppagamento';


--
-- TOC entry 2144 (class 0 OID 0)
-- Dependencies: 1569
-- Name: COLUMN pgto_efetuado.id_cliente; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pgto_efetuado.id_cliente IS 'id_cliente';


--
-- TOC entry 2145 (class 0 OID 0)
-- Dependencies: 1569
-- Name: COLUMN pgto_efetuado.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pgto_efetuado.id_status IS 'id_status';


--
-- TOC entry 2146 (class 0 OID 0)
-- Dependencies: 1569
-- Name: COLUMN pgto_efetuado.dt_pagamento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN pgto_efetuado.dt_pagamento IS 'dt_pagamento';


--
-- TOC entry 1570 (class 1259 OID 16478)
-- Dependencies: 6
-- Name: produtos; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE produtos (
    id_produto integer NOT NULL,
    id_funcionario integer,
    id_fornecedor integer,
    id_categoria integer,
    id_status integer,
    descricao character varying(50) NOT NULL,
    qtde numeric,
    qtde_critica numeric,
    vlr_compra numeric(9,2),
    vlr_venda numeric(9,2),
    limite_desconto numeric,
    status numeric(1,0),
    data_criacao timestamp without time zone,
    data_modificacao timestamp without time zone,
    id_funcionario_mod integer
);


--
-- TOC entry 2147 (class 0 OID 0)
-- Dependencies: 1570
-- Name: TABLE produtos; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE produtos IS 'TABELA RESPONSAVEL POR ARMAZENAR INFORMACOES DOS PRODUTOS';


--
-- TOC entry 2148 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.id_produto; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.id_produto IS 'id_produto';


--
-- TOC entry 2149 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.id_funcionario; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.id_funcionario IS 'id_funcionario';


--
-- TOC entry 2150 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.id_fornecedor; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.id_fornecedor IS 'id_fornecedor';


--
-- TOC entry 2151 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.id_categoria; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.id_categoria IS 'id_categoria';


--
-- TOC entry 2152 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.id_status IS 'id_status';


--
-- TOC entry 2153 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.descricao IS 'descricao';


--
-- TOC entry 2154 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.qtde; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.qtde IS 'qtde';


--
-- TOC entry 2155 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.qtde_critica; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.qtde_critica IS 'qtde_critica';


--
-- TOC entry 2156 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.vlr_compra; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.vlr_compra IS 'vlr_compra';


--
-- TOC entry 2157 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.vlr_venda; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.vlr_venda IS 'vlr_venda';


--
-- TOC entry 2158 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.limite_desconto; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.limite_desconto IS 'limite_desconto';


--
-- TOC entry 2159 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.status IS 'status';


--
-- TOC entry 2160 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.data_criacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.data_criacao IS 'data_criacao';


--
-- TOC entry 2161 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.data_modificacao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.data_modificacao IS 'data_modificacao';


--
-- TOC entry 2162 (class 0 OID 0)
-- Dependencies: 1570
-- Name: COLUMN produtos.id_funcionario_mod; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN produtos.id_funcionario_mod IS 'Id_funcionario_mod';


--
-- TOC entry 1571 (class 1259 OID 16484)
-- Dependencies: 6 1570
-- Name: produtos_id_produto_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE produtos_id_produto_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2163 (class 0 OID 0)
-- Dependencies: 1571
-- Name: produtos_id_produto_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE produtos_id_produto_seq OWNED BY produtos.id_produto;


--
-- TOC entry 1572 (class 1259 OID 16486)
-- Dependencies: 6
-- Name: status; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE status (
    id_status integer NOT NULL,
    descricao character varying(50)
);


--
-- TOC entry 2164 (class 0 OID 0)
-- Dependencies: 1572
-- Name: TABLE status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE status IS 'Tabela com todos os status';


--
-- TOC entry 2165 (class 0 OID 0)
-- Dependencies: 1572
-- Name: COLUMN status.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN status.id_status IS 'id_status';


--
-- TOC entry 2166 (class 0 OID 0)
-- Dependencies: 1572
-- Name: COLUMN status.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN status.descricao IS 'descricao';


--
-- TOC entry 1573 (class 1259 OID 16489)
-- Dependencies: 1572 6
-- Name: status_id_status_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE status_id_status_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2167 (class 0 OID 0)
-- Dependencies: 1573
-- Name: status_id_status_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE status_id_status_seq OWNED BY status.id_status;


--
-- TOC entry 1574 (class 1259 OID 16491)
-- Dependencies: 6
-- Name: tp_enderecos; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE tp_enderecos (
    id_tpendereco integer NOT NULL,
    descricao character varying(20)
);


--
-- TOC entry 2168 (class 0 OID 0)
-- Dependencies: 1574
-- Name: TABLE tp_enderecos; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE tp_enderecos IS 'Tabela com os tipos dos endereços do sistema';


--
-- TOC entry 2169 (class 0 OID 0)
-- Dependencies: 1574
-- Name: COLUMN tp_enderecos.id_tpendereco; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_enderecos.id_tpendereco IS 'id_tpendereco';


--
-- TOC entry 2170 (class 0 OID 0)
-- Dependencies: 1574
-- Name: COLUMN tp_enderecos.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_enderecos.descricao IS 'descricao';


--
-- TOC entry 1575 (class 1259 OID 16494)
-- Dependencies: 6 1574
-- Name: tp_enderecos_id_tpendereco_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE tp_enderecos_id_tpendereco_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2171 (class 0 OID 0)
-- Dependencies: 1575
-- Name: tp_enderecos_id_tpendereco_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE tp_enderecos_id_tpendereco_seq OWNED BY tp_enderecos.id_tpendereco;


--
-- TOC entry 1576 (class 1259 OID 16496)
-- Dependencies: 6
-- Name: tp_ocorrencias; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE tp_ocorrencias (
    id_ocorrencia integer NOT NULL,
    id_status integer,
    descricao character varying(50)
);


--
-- TOC entry 2172 (class 0 OID 0)
-- Dependencies: 1576
-- Name: TABLE tp_ocorrencias; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE tp_ocorrencias IS 'Tabela com os tipos de ocorrencia';


--
-- TOC entry 2173 (class 0 OID 0)
-- Dependencies: 1576
-- Name: COLUMN tp_ocorrencias.id_ocorrencia; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_ocorrencias.id_ocorrencia IS 'id_ocorrencia';


--
-- TOC entry 2174 (class 0 OID 0)
-- Dependencies: 1576
-- Name: COLUMN tp_ocorrencias.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_ocorrencias.id_status IS 'id_status';


--
-- TOC entry 2175 (class 0 OID 0)
-- Dependencies: 1576
-- Name: COLUMN tp_ocorrencias.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_ocorrencias.descricao IS 'descricao';


--
-- TOC entry 1577 (class 1259 OID 16499)
-- Dependencies: 6 1576
-- Name: tp_ocorrencias_id_ocorrencia_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE tp_ocorrencias_id_ocorrencia_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2176 (class 0 OID 0)
-- Dependencies: 1577
-- Name: tp_ocorrencias_id_ocorrencia_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE tp_ocorrencias_id_ocorrencia_seq OWNED BY tp_ocorrencias.id_ocorrencia;


--
-- TOC entry 1578 (class 1259 OID 16501)
-- Dependencies: 6
-- Name: tp_pagamentos; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE tp_pagamentos (
    id_tppagamento integer NOT NULL,
    id_status integer,
    descricao character varying(50),
    status numeric(1,0)
);


--
-- TOC entry 2177 (class 0 OID 0)
-- Dependencies: 1578
-- Name: TABLE tp_pagamentos; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE tp_pagamentos IS 'FORMAS DE PAGAMENTOS';


--
-- TOC entry 2178 (class 0 OID 0)
-- Dependencies: 1578
-- Name: COLUMN tp_pagamentos.id_tppagamento; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_pagamentos.id_tppagamento IS 'id_tppagamento';


--
-- TOC entry 2179 (class 0 OID 0)
-- Dependencies: 1578
-- Name: COLUMN tp_pagamentos.id_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_pagamentos.id_status IS 'id_status';


--
-- TOC entry 2180 (class 0 OID 0)
-- Dependencies: 1578
-- Name: COLUMN tp_pagamentos.descricao; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_pagamentos.descricao IS 'descricao';


--
-- TOC entry 2181 (class 0 OID 0)
-- Dependencies: 1578
-- Name: COLUMN tp_pagamentos.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN tp_pagamentos.status IS 'status';


--
-- TOC entry 1579 (class 1259 OID 16504)
-- Dependencies: 1578 6
-- Name: tp_pagamentos_id_tppagamento_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE tp_pagamentos_id_tppagamento_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 2182 (class 0 OID 0)
-- Dependencies: 1579
-- Name: tp_pagamentos_id_tppagamento_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE tp_pagamentos_id_tppagamento_seq OWNED BY tp_pagamentos.id_tppagamento;


--
-- TOC entry 1857 (class 2604 OID 16767)
-- Dependencies: 1548 1547
-- Name: id_banco; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE banco ALTER COLUMN id_banco SET DEFAULT nextval('banco_id_banco_seq'::regclass);


--
-- TOC entry 1858 (class 2604 OID 16768)
-- Dependencies: 1550 1549
-- Name: id_categoria; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE categoria ALTER COLUMN id_categoria SET DEFAULT nextval('categoria_id_categoria_seq'::regclass);


--
-- TOC entry 1860 (class 2604 OID 16769)
-- Dependencies: 1552 1551
-- Name: id_cliente; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE clientes ALTER COLUMN id_cliente SET DEFAULT nextval('clientes_id_cliente_seq'::regclass);


--
-- TOC entry 1861 (class 2604 OID 16770)
-- Dependencies: 1554 1553
-- Name: id_departamento; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE departamentos ALTER COLUMN id_departamento SET DEFAULT nextval('departamentos_id_departamento_seq'::regclass);


--
-- TOC entry 1864 (class 2604 OID 16771)
-- Dependencies: 1557 1556
-- Name: id_fornecedor; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE fornecedores ALTER COLUMN id_fornecedor SET DEFAULT nextval('fornecedores_id_fornecedor_seq'::regclass);


--
-- TOC entry 1867 (class 2604 OID 16772)
-- Dependencies: 1559 1558
-- Name: id_funcionario; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE funcionarios ALTER COLUMN id_funcionario SET DEFAULT nextval('funcionarios_id_funcionario_seq'::regclass);


--
-- TOC entry 1868 (class 2604 OID 16773)
-- Dependencies: 1561 1560
-- Name: id_funcao; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE funcoes ALTER COLUMN id_funcao SET DEFAULT nextval('funcoes_id_funcao_seq'::regclass);


--
-- TOC entry 1869 (class 2604 OID 16774)
-- Dependencies: 1564 1563
-- Name: id_log; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE log_sistema ALTER COLUMN id_log SET DEFAULT nextval('log_sistema_id_log_seq'::regclass);


--
-- TOC entry 1870 (class 2604 OID 16775)
-- Dependencies: 1568 1565
-- Name: id_pedido; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE pedidos ALTER COLUMN id_pedido SET DEFAULT nextval('pedidos_id_pedido_seq'::regclass);


--
-- TOC entry 1871 (class 2604 OID 16776)
-- Dependencies: 1567 1566
-- Name: id_pedidodet; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE pedidos_det ALTER COLUMN id_pedidodet SET DEFAULT nextval('pedidos_det_id_pedidodet_seq'::regclass);


--
-- TOC entry 1872 (class 2604 OID 16777)
-- Dependencies: 1571 1570
-- Name: id_produto; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE produtos ALTER COLUMN id_produto SET DEFAULT nextval('produtos_id_produto_seq'::regclass);


--
-- TOC entry 1873 (class 2604 OID 16778)
-- Dependencies: 1573 1572
-- Name: id_status; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE status ALTER COLUMN id_status SET DEFAULT nextval('status_id_status_seq'::regclass);


--
-- TOC entry 1874 (class 2604 OID 16779)
-- Dependencies: 1575 1574
-- Name: id_tpendereco; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE tp_enderecos ALTER COLUMN id_tpendereco SET DEFAULT nextval('tp_enderecos_id_tpendereco_seq'::regclass);


--
-- TOC entry 1875 (class 2604 OID 16780)
-- Dependencies: 1577 1576
-- Name: id_ocorrencia; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE tp_ocorrencias ALTER COLUMN id_ocorrencia SET DEFAULT nextval('tp_ocorrencias_id_ocorrencia_seq'::regclass);


--
-- TOC entry 1876 (class 2604 OID 16781)
-- Dependencies: 1579 1578
-- Name: id_tppagamento; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE tp_pagamentos ALTER COLUMN id_tppagamento SET DEFAULT nextval('tp_pagamentos_id_tppagamento_seq'::regclass);


--
-- TOC entry 1879 (class 2606 OID 16522)
-- Dependencies: 1547 1547
-- Name: pk_banco; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY banco
    ADD CONSTRAINT pk_banco PRIMARY KEY (id_banco);


--
-- TOC entry 1882 (class 2606 OID 16524)
-- Dependencies: 1549 1549
-- Name: pk_categoria; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY categoria
    ADD CONSTRAINT pk_categoria PRIMARY KEY (id_categoria);


--
-- TOC entry 1888 (class 2606 OID 16526)
-- Dependencies: 1551 1551
-- Name: pk_clientes; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY clientes
    ADD CONSTRAINT pk_clientes PRIMARY KEY (id_cliente);


--
-- TOC entry 1891 (class 2606 OID 16528)
-- Dependencies: 1553 1553
-- Name: pk_departamentos; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY departamentos
    ADD CONSTRAINT pk_departamentos PRIMARY KEY (id_departamento);


--
-- TOC entry 1898 (class 2606 OID 16530)
-- Dependencies: 1555 1555
-- Name: pk_enderecos; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY enderecos
    ADD CONSTRAINT pk_enderecos PRIMARY KEY (id_endereco);


--
-- TOC entry 1906 (class 2606 OID 16532)
-- Dependencies: 1556 1556
-- Name: pk_fornecedores; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY fornecedores
    ADD CONSTRAINT pk_fornecedores PRIMARY KEY (id_fornecedor);


--
-- TOC entry 1912 (class 2606 OID 16534)
-- Dependencies: 1558 1558
-- Name: pk_funcionarios; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY funcionarios
    ADD CONSTRAINT pk_funcionarios PRIMARY KEY (id_funcionario);


--
-- TOC entry 1916 (class 2606 OID 16536)
-- Dependencies: 1560 1560
-- Name: pk_funcoes; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY funcoes
    ADD CONSTRAINT pk_funcoes PRIMARY KEY (id_funcao);


--
-- TOC entry 1919 (class 2606 OID 16538)
-- Dependencies: 1563 1563
-- Name: pk_log_sistema; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY log_sistema
    ADD CONSTRAINT pk_log_sistema PRIMARY KEY (id_log);


--
-- TOC entry 1925 (class 2606 OID 16540)
-- Dependencies: 1565 1565
-- Name: pk_pedidos; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY pedidos
    ADD CONSTRAINT pk_pedidos PRIMARY KEY (id_pedido);


--
-- TOC entry 1930 (class 2606 OID 16542)
-- Dependencies: 1566 1566
-- Name: pk_pedidos_det; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY pedidos_det
    ADD CONSTRAINT pk_pedidos_det PRIMARY KEY (id_pedidodet);


--
-- TOC entry 1935 (class 2606 OID 16544)
-- Dependencies: 1569 1569
-- Name: pk_pgto_efetuado; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY pgto_efetuado
    ADD CONSTRAINT pk_pgto_efetuado PRIMARY KEY (id_pgtoefetuado);


--
-- TOC entry 1940 (class 2606 OID 16546)
-- Dependencies: 1570 1570
-- Name: pk_produtos; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY produtos
    ADD CONSTRAINT pk_produtos PRIMARY KEY (id_produto);


--
-- TOC entry 1943 (class 2606 OID 16548)
-- Dependencies: 1572 1572
-- Name: pk_status; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY status
    ADD CONSTRAINT pk_status PRIMARY KEY (id_status);


--
-- TOC entry 1946 (class 2606 OID 16550)
-- Dependencies: 1574 1574
-- Name: pk_tp_enderecos; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY tp_enderecos
    ADD CONSTRAINT pk_tp_enderecos PRIMARY KEY (id_tpendereco);


--
-- TOC entry 1949 (class 2606 OID 16552)
-- Dependencies: 1576 1576
-- Name: pk_tp_ocorrencias; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY tp_ocorrencias
    ADD CONSTRAINT pk_tp_ocorrencias PRIMARY KEY (id_ocorrencia);


--
-- TOC entry 1952 (class 2606 OID 16554)
-- Dependencies: 1578 1578
-- Name: pk_tp_pagamentos; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY tp_pagamentos
    ADD CONSTRAINT pk_tp_pagamentos PRIMARY KEY (id_tppagamento);


--
-- TOC entry 1883 (class 1259 OID 16555)
-- Dependencies: 1551 1551 1551
-- Name: idx_cliente; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_cliente ON clientes USING btree (nome, cpf, rg);


--
-- TOC entry 1899 (class 1259 OID 16556)
-- Dependencies: 1556
-- Name: idx_cnpj_forne; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_cnpj_forne ON fornecedores USING btree (cnpj);


--
-- TOC entry 1936 (class 1259 OID 16557)
-- Dependencies: 1570 1570
-- Name: idx_com_ven_produto; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_com_ven_produto ON produtos USING btree (vlr_compra, vlr_venda);


--
-- TOC entry 1884 (class 1259 OID 16558)
-- Dependencies: 1551
-- Name: idx_cpf_cliente; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_cpf_cliente ON clientes USING btree (cpf);


--
-- TOC entry 1877 (class 1259 OID 16559)
-- Dependencies: 1547
-- Name: idx_descricao_banco; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_descricao_banco ON banco USING btree (descricao);


--
-- TOC entry 1880 (class 1259 OID 16560)
-- Dependencies: 1549
-- Name: idx_descricao_cate; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_descricao_cate ON categoria USING btree (descricao);


--
-- TOC entry 1889 (class 1259 OID 16561)
-- Dependencies: 1553
-- Name: idx_descricao_depart; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_descricao_depart ON departamentos USING btree (descricao);


--
-- TOC entry 1937 (class 1259 OID 16562)
-- Dependencies: 1570
-- Name: idx_descricao_produto; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_descricao_produto ON produtos USING btree (descricao);


--
-- TOC entry 1920 (class 1259 OID 16563)
-- Dependencies: 1565
-- Name: idx_dt_ultimo_pgto; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_dt_ultimo_pgto ON pedidos USING btree (dt_utlimo_pgto);


--
-- TOC entry 1892 (class 1259 OID 16564)
-- Dependencies: 1555
-- Name: idx_end_bairro; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_end_bairro ON enderecos USING btree (bairro);


--
-- TOC entry 1893 (class 1259 OID 16565)
-- Dependencies: 1555
-- Name: idx_end_cidade; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_end_cidade ON enderecos USING btree (cidade);


--
-- TOC entry 1894 (class 1259 OID 16566)
-- Dependencies: 1555
-- Name: idx_end_estado; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_end_estado ON enderecos USING btree (estado);


--
-- TOC entry 1895 (class 1259 OID 16567)
-- Dependencies: 1555
-- Name: idx_end_rua; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_end_rua ON enderecos USING btree (logradouro);


--
-- TOC entry 1896 (class 1259 OID 16568)
-- Dependencies: 1555 1555 1555 1555
-- Name: idx_endereco; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_endereco ON enderecos USING btree (logradouro, bairro, cidade, estado);


--
-- TOC entry 1900 (class 1259 OID 16569)
-- Dependencies: 1556
-- Name: idx_fantasia_forne; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_fantasia_forne ON fornecedores USING btree (nome_fantasia);


--
-- TOC entry 1938 (class 1259 OID 16570)
-- Dependencies: 1570 1570
-- Name: idx_forne_cat_produto; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_forne_cat_produto ON produtos USING btree (id_fornecedor, id_categoria);


--
-- TOC entry 1901 (class 1259 OID 16571)
-- Dependencies: 1556 1556 1556 1556 1556
-- Name: idx_fornecedor; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_fornecedor ON fornecedores USING btree (nome_fantasia, razao_social, tipo, cnpj, status);


--
-- TOC entry 1913 (class 1259 OID 16572)
-- Dependencies: 1560
-- Name: idx_funca_dep; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_funca_dep ON funcoes USING btree (id_departamento);


--
-- TOC entry 1914 (class 1259 OID 16573)
-- Dependencies: 1560
-- Name: idx_funcao_desc; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_funcao_desc ON funcoes USING btree (descricao);


--
-- TOC entry 1907 (class 1259 OID 16574)
-- Dependencies: 1558 1558 1558
-- Name: idx_funcionarios; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_funcionarios ON funcionarios USING btree (nomeusuario, nome, cpf);


--
-- TOC entry 1917 (class 1259 OID 16575)
-- Dependencies: 1563
-- Name: idx_log_idocorrencia; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_log_idocorrencia ON log_sistema USING btree (id_ocorrencia);


--
-- TOC entry 1908 (class 1259 OID 16576)
-- Dependencies: 1558
-- Name: idx_name_employees; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_name_employees ON funcionarios USING btree (nome);


--
-- TOC entry 1885 (class 1259 OID 16577)
-- Dependencies: 1551
-- Name: idx_nome_cliente; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_nome_cliente ON clientes USING btree (nome);


--
-- TOC entry 1950 (class 1259 OID 16578)
-- Dependencies: 1578 1578
-- Name: idx_pagamento_desc; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_pagamento_desc ON tp_pagamentos USING btree (descricao, status);


--
-- TOC entry 1921 (class 1259 OID 16579)
-- Dependencies: 1565 1565 1565
-- Name: idx_ped_cliente_nota; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_ped_cliente_nota ON pedidos USING btree (id_pedido, id_cliente, numnota);


--
-- TOC entry 1926 (class 1259 OID 16580)
-- Dependencies: 1566
-- Name: idx_peddet_numnota; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_peddet_numnota ON pedidos_det USING btree (numnota);


--
-- TOC entry 1927 (class 1259 OID 16581)
-- Dependencies: 1566
-- Name: idx_peddet_ped; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_peddet_ped ON pedidos_det USING btree (id_pedido);


--
-- TOC entry 1928 (class 1259 OID 16582)
-- Dependencies: 1566 1566 1566 1566
-- Name: idx_peddet_ped_pro; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_peddet_ped_pro ON pedidos_det USING btree (id_pedidodet, id_pedido, id_produto, numnota);


--
-- TOC entry 1922 (class 1259 OID 16583)
-- Dependencies: 1565
-- Name: idx_pedido_cliente; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_pedido_cliente ON pedidos USING btree (id_cliente);


--
-- TOC entry 1923 (class 1259 OID 16584)
-- Dependencies: 1565
-- Name: idx_pedido_numnota; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_pedido_numnota ON pedidos USING btree (numnota);


--
-- TOC entry 1931 (class 1259 OID 16585)
-- Dependencies: 1569
-- Name: idx_pgto_dt; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_pgto_dt ON pgto_efetuado USING btree (dt_pagamento);


--
-- TOC entry 1932 (class 1259 OID 16586)
-- Dependencies: 1569 1569 1569 1569
-- Name: idx_pgto_efetuado; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_pgto_efetuado ON pgto_efetuado USING btree (id_pedido, id_funcionario, id_tppagamento, id_cliente);


--
-- TOC entry 1933 (class 1259 OID 16587)
-- Dependencies: 1569
-- Name: idx_pgto_status; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_pgto_status ON pgto_efetuado USING btree (id_status);


--
-- TOC entry 1902 (class 1259 OID 16588)
-- Dependencies: 1556
-- Name: idx_razao_forne; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_razao_forne ON fornecedores USING btree (razao_social);


--
-- TOC entry 1886 (class 1259 OID 16589)
-- Dependencies: 1551
-- Name: idx_rg_cliente; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_rg_cliente ON clientes USING btree (rg);


--
-- TOC entry 1909 (class 1259 OID 16590)
-- Dependencies: 1558
-- Name: idx_ssn_employees; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_ssn_employees ON funcionarios USING btree (cpf);


--
-- TOC entry 1941 (class 1259 OID 16591)
-- Dependencies: 1572
-- Name: idx_status_desc; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_status_desc ON status USING btree (descricao);


--
-- TOC entry 1903 (class 1259 OID 16592)
-- Dependencies: 1556
-- Name: idx_status_forne; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_status_forne ON fornecedores USING btree (status);


--
-- TOC entry 1904 (class 1259 OID 16593)
-- Dependencies: 1556
-- Name: idx_tipo_forne; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_tipo_forne ON fornecedores USING btree (tipo);


--
-- TOC entry 1944 (class 1259 OID 16594)
-- Dependencies: 1574
-- Name: idx_tp_endereco; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_tp_endereco ON tp_enderecos USING btree (descricao);


--
-- TOC entry 1947 (class 1259 OID 16595)
-- Dependencies: 1576
-- Name: idx_tpocorrencia_desc; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_tpocorrencia_desc ON tp_ocorrencias USING btree (descricao);


--
-- TOC entry 1910 (class 1259 OID 16596)
-- Dependencies: 1558
-- Name: idx_username_employees; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX idx_username_employees ON funcionarios USING btree (nomeusuario);


--
-- TOC entry 1960 (class 2606 OID 16597)
-- Dependencies: 1555 1574 1945
-- Name: fk_adress_tp_end; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY enderecos
    ADD CONSTRAINT fk_adress_tp_end FOREIGN KEY (id_tpendereco) REFERENCES tp_enderecos(id_tpendereco) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1953 (class 2606 OID 16602)
-- Dependencies: 1547 1558 1911
-- Name: fk_banco_func; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY banco
    ADD CONSTRAINT fk_banco_func FOREIGN KEY (id_funcionario) REFERENCES funcionarios(id_funcionario) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1954 (class 2606 OID 16607)
-- Dependencies: 1547 1572 1942
-- Name: fk_banco_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY banco
    ADD CONSTRAINT fk_banco_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1955 (class 2606 OID 16612)
-- Dependencies: 1549 1572 1942
-- Name: fk_cat_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY categoria
    ADD CONSTRAINT fk_cat_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1956 (class 2606 OID 16617)
-- Dependencies: 1551 1878 1547
-- Name: fk_cliente_banco; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY clientes
    ADD CONSTRAINT fk_cliente_banco FOREIGN KEY (id_banco) REFERENCES banco(id_banco) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1957 (class 2606 OID 16622)
-- Dependencies: 1551 1911 1558
-- Name: fk_cliente_func; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY clientes
    ADD CONSTRAINT fk_cliente_func FOREIGN KEY (id_funcionario) REFERENCES funcionarios(id_funcionario);


--
-- TOC entry 1958 (class 2606 OID 16627)
-- Dependencies: 1551 1942 1572
-- Name: fk_clientes_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY clientes
    ADD CONSTRAINT fk_clientes_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1959 (class 2606 OID 16632)
-- Dependencies: 1553 1942 1572
-- Name: fk_dep_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY departamentos
    ADD CONSTRAINT fk_dep_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1963 (class 2606 OID 16637)
-- Dependencies: 1560 1915 1558
-- Name: fk_emp_func; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY funcionarios
    ADD CONSTRAINT fk_emp_func FOREIGN KEY (id_funcao) REFERENCES funcoes(id_funcao);


--
-- TOC entry 1961 (class 2606 OID 16642)
-- Dependencies: 1911 1558 1556
-- Name: fk_forne_func; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY fornecedores
    ADD CONSTRAINT fk_forne_func FOREIGN KEY (id_funcionario) REFERENCES funcionarios(id_funcionario);


--
-- TOC entry 1962 (class 2606 OID 16647)
-- Dependencies: 1572 1556 1942
-- Name: fk_forne_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY fornecedores
    ADD CONSTRAINT fk_forne_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1966 (class 2606 OID 16652)
-- Dependencies: 1553 1890 1560
-- Name: fk_func_dep; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY funcoes
    ADD CONSTRAINT fk_func_dep FOREIGN KEY (id_departamento) REFERENCES departamentos(id_departamento);


--
-- TOC entry 1964 (class 2606 OID 16657)
-- Dependencies: 1572 1942 1558
-- Name: fk_func_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY funcionarios
    ADD CONSTRAINT fk_func_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1965 (class 2606 OID 16662)
-- Dependencies: 1558 1553 1890
-- Name: fk_funcionario_dep; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY funcionarios
    ADD CONSTRAINT fk_funcionario_dep FOREIGN KEY (id_departamento) REFERENCES departamentos(id_departamento) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1967 (class 2606 OID 16667)
-- Dependencies: 1560 1942 1572
-- Name: fk_funcoes_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY funcoes
    ADD CONSTRAINT fk_funcoes_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1968 (class 2606 OID 16672)
-- Dependencies: 1562 1551 1887
-- Name: fk_inadiple_reference_clientes; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY inadiplentes
    ADD CONSTRAINT fk_inadiple_reference_clientes FOREIGN KEY (id_cliente) REFERENCES clientes(id_cliente) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1969 (class 2606 OID 16677)
-- Dependencies: 1948 1563 1576
-- Name: fk_log_user_tpoco; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY log_sistema
    ADD CONSTRAINT fk_log_user_tpoco FOREIGN KEY (id_ocorrencia) REFERENCES tp_ocorrencias(id_ocorrencia) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1970 (class 2606 OID 16682)
-- Dependencies: 1572 1565 1942
-- Name: fk_pedido_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pedidos
    ADD CONSTRAINT fk_pedido_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1971 (class 2606 OID 16687)
-- Dependencies: 1551 1565 1887
-- Name: fk_pedidos_cli; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pedidos
    ADD CONSTRAINT fk_pedidos_cli FOREIGN KEY (id_cliente) REFERENCES clientes(id_cliente) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1972 (class 2606 OID 16692)
-- Dependencies: 1558 1565 1911
-- Name: fk_pedidos_func; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pedidos
    ADD CONSTRAINT fk_pedidos_func FOREIGN KEY (id_funcionario) REFERENCES funcionarios(id_funcionario) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1974 (class 2606 OID 16697)
-- Dependencies: 1565 1566 1924
-- Name: fk_pedidos_ped_det; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pedidos_det
    ADD CONSTRAINT fk_pedidos_ped_det FOREIGN KEY (id_pedido) REFERENCES pedidos(id_pedido) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1975 (class 2606 OID 16702)
-- Dependencies: 1939 1570 1566
-- Name: fk_pedidos_produtos; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pedidos_det
    ADD CONSTRAINT fk_pedidos_produtos FOREIGN KEY (id_produto) REFERENCES produtos(id_produto) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1973 (class 2606 OID 16707)
-- Dependencies: 1565 1951 1578
-- Name: fk_pedidos_tppgto; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pedidos
    ADD CONSTRAINT fk_pedidos_tppgto FOREIGN KEY (id_pagamento) REFERENCES tp_pagamentos(id_tppagamento) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1976 (class 2606 OID 16712)
-- Dependencies: 1569 1887 1551
-- Name: fk_pgto_efec_clientes; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pgto_efetuado
    ADD CONSTRAINT fk_pgto_efec_clientes FOREIGN KEY (id_cliente) REFERENCES clientes(id_cliente) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1977 (class 2606 OID 16717)
-- Dependencies: 1569 1911 1558
-- Name: fk_pgto_efec_func; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pgto_efetuado
    ADD CONSTRAINT fk_pgto_efec_func FOREIGN KEY (id_funcionario) REFERENCES funcionarios(id_funcionario) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1978 (class 2606 OID 16722)
-- Dependencies: 1565 1924 1569
-- Name: fk_pgto_efec_pedidos; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pgto_efetuado
    ADD CONSTRAINT fk_pgto_efec_pedidos FOREIGN KEY (id_pedido) REFERENCES pedidos(id_pedido) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1979 (class 2606 OID 16727)
-- Dependencies: 1569 1572 1942
-- Name: fk_pgto_efec_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pgto_efetuado
    ADD CONSTRAINT fk_pgto_efec_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1980 (class 2606 OID 16732)
-- Dependencies: 1951 1569 1578
-- Name: fk_pgto_efec_tp_pag; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY pgto_efetuado
    ADD CONSTRAINT fk_pgto_efec_tp_pag FOREIGN KEY (id_tppagamento) REFERENCES tp_pagamentos(id_tppagamento) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1981 (class 2606 OID 16737)
-- Dependencies: 1549 1570 1881
-- Name: fk_produtos_cat; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY produtos
    ADD CONSTRAINT fk_produtos_cat FOREIGN KEY (id_categoria) REFERENCES categoria(id_categoria) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1982 (class 2606 OID 16742)
-- Dependencies: 1570 1905 1556
-- Name: fk_produtos_forne; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY produtos
    ADD CONSTRAINT fk_produtos_forne FOREIGN KEY (id_fornecedor) REFERENCES fornecedores(id_fornecedor) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1983 (class 2606 OID 16747)
-- Dependencies: 1570 1911 1558
-- Name: fk_produtos_func; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY produtos
    ADD CONSTRAINT fk_produtos_func FOREIGN KEY (id_funcionario) REFERENCES funcionarios(id_funcionario) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1984 (class 2606 OID 16752)
-- Dependencies: 1942 1572 1570
-- Name: fk_produtos_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY produtos
    ADD CONSTRAINT fk_produtos_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1985 (class 2606 OID 16757)
-- Dependencies: 1576 1942 1572
-- Name: fk_tipo_oco_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY tp_ocorrencias
    ADD CONSTRAINT fk_tipo_oco_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1986 (class 2606 OID 16762)
-- Dependencies: 1572 1578 1942
-- Name: fk_tppgto_status; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY tp_pagamentos
    ADD CONSTRAINT fk_tppgto_status FOREIGN KEY (id_status) REFERENCES status(id_status) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- TOC entry 1991 (class 0 OID 0)
-- Dependencies: 6
-- Name: public; Type: ACL; Schema: -; Owner: -
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


-- Completed on 2011-05-30 23:04:41

--
-- PostgreSQL database dump complete
--

